package cn.itsnkkka;

import java.util.Scanner;

public class Work_01 {

    public static class Student{
        private String sName;
        private int sJava;

        public Student(
                String sName,
                int sJava
        ) {
            this.sName = sName;
            this.sJava = sJava;
        }

        public String getsName() {
            return sName;
        }

        public int getsJava() {
            return sJava;
        }


    }

    public static void main(String[] args) {
        Student[] students = new Student[5];
        Scanner scanner = new Scanner(System.in);

        Student maxStudent = null;
        Student minStudent = null;
        int avgScore = 0;

        for (int i = 0; i < students.length; i++) {

            students[i] = new Student(scanner.next(), scanner.nextInt());

            if (null == maxStudent || students[i].getsJava() >= maxStudent.getsJava()) {
                maxStudent = students[i];
            }

            if (null == minStudent || students[i].getsJava() < minStudent.getsJava()) {
                minStudent = students[i];
            }

            avgScore+=students[i].getsJava();

        }

        System.out.println(
                String.format(
                        "5位学生的最高分、最低分和平均分是：\n" +
                                "\n" +
                                "最高分学生信息：%s,Java课成绩%d\n" +
                                "\n" +
                                "最低分学生信息：%s,Java课成绩%d\n" +
                                "\n" +
                                "5个同学的平均成绩是:%d",
                        maxStudent.getsName(), maxStudent.getsJava(),
                        minStudent.getsName(), minStudent.getsJava(),
                        avgScore / students.length
                )
        );

    }

}
